home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_gen_doortalk.cog < prev    next >
Text File  |  1999-11-15  |  16KB  |  583 lines

  1. # Jones 3D Cog Script
  2. #
  3. # gen_DoorTalk.cog
  4. #
  5. # Indy talks a lot around doors
  6. #
  7. # [HB; thanks to Pat M & Tim M]
  8. #
  9. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  10. # ==============================================================================
  11.  
  12. # NOTE: This is a random verbal door reaction cog.  Glue it into your level and
  13. # reach it from a calling cog like this:
  14. #
  15. # 1. Create a valid reference to this cog in your calling cog;
  16. #
  17. # 2. Use the following verb:
  18. #    SendMessageEx(thiscogREF, i_userMessage, f_parm0, f_parm1, f_parm2, f_parm3);
  19. #    (see each section below for details...)
  20. #
  21. # 3. Use global15 as a semaphore and return value where neeeded;
  22. #
  23. # The resulting chatter is pre-approved by HB...
  24. #
  25. # PRODUCT SUPPORT:  cogsrus x8371
  26.  
  27. # ==============================================================================
  28.  
  29. symbols
  30.  
  31. # ................................. MESSAGES ...................................
  32.  
  33.     message user0    # locked door reaction: right key, wrong key, wrong item, no item
  34.     message user1    # right key
  35.     message user2    # wrong key
  36.     message user3    # wrong item
  37.     message user4    # no item
  38.     message user5    # things that won't open
  39.  
  40. # ................................ SUBROUTINES .................................
  41.  
  42.     flex    checkforkey                            local        
  43.     flex    randrightkeylines                    local
  44.     flex    randwrongkeylines                    local
  45.     flex    randwrongitemlines                    local
  46.     flex    randlocklines                        local
  47.     flex    randwontopenlines                    local
  48.  
  49. # ................................. SAY LINES ..................................
  50.  
  51.     # right key lines...
  52.     sound    in_sayline=Inxj110.wav                local # Success!-->in_sayline[0]
  53.     sound    in_there=Inxj108.wav                local # There!
  54.     sound    in_fits=Inxj109.wav                    local # It fits!
  55.     sound    in_whoaopen=Inxj103.wav                local # Whoa! It opened.
  56.     sound    in_worked=Inxj111.wav                local # what...know...worked!
  57.     sound    in_gotlucky=Inxj106.wav                local # ...got lucky.
  58.     sound    in_damnopen=Inxj105.wav                local # ...be damned...opened.
  59.     
  60.     # wrong key lines...
  61.     sound    in_mustwrongkey=Inxj083.wav            local # Hmm...wrong key-->in_sayline[7]
  62.     sound    in_wrongkey=Inxj084.wav                local # Wrong key.
  63.     sound    in_guesswrongkey=Inxj085.wav        local # I guess...wrong key.
  64.     sound    in_ifkeywrong=Inxj086.wav            local # If key...wrong key.
  65.  
  66.     # wrong item lines...
  67.     sound    in_nowork=Inxj089.wav                local # That didn't work-->in_sayline[11]
  68.     sound    in_somethingwrong=Inxj090.wav        local # ...something wrong.
  69.     sound    in_hmnotquite=Inxj092.wav            local # Hmm...didn't quite work.
  70.     sound    in_notright=Inxj060.wav                local # I don't think...right answer
  71.     sound    in_whoops=Inxj087.wav                local # Whoops.
  72.     sound    in_nope=Inxj088.wav                    local # Nope.
  73.     sound    in_ofcourseno=Inxj091.wav            local # Of course that didn't work.    
  74.  
  75.     # door locked lines...
  76.     sound    in_doorlocked=Inxj076.wav            local # This...locked-->in_sayline[18]
  77.     sound    in_islocked=Inxj077.wav                local # It's locked.
  78.     sound    in_locked=Inxj078.wav                local # Locked.
  79.     sound    in_keyhole=Inxj082.wav                local # keyhole here...just need key.
  80.     sound    in_lockedagain=Inxj079.wav            local # Locked again.
  81.     sound    in_lockedluck=Inxj080.wav            local # Locked...luck never changes.
  82.     sound    in_whyalwayslocked=Inxj081.wav        local # Oh no...why...always locked?
  83.  
  84.     # just won't open lines...
  85.     sound    in_cantopen=Inxj096.wav                local # I can't open it-->insayline[25]
  86.     sound    in_somereadon=Inxj097.wav            local # For some reason...won't open.
  87.     sound    in_nobudge=Inxj098.wav                local # It won't budge.
  88.     sound    in_holdingdoor=Inxj099.wav            local # Something is holding this door closed.
  89.     sound    in_dontknow=Inxj102.wav                local # must be way...don't know how.
  90.  
  91. # ............................... VARIABLES ....................................
  92.  
  93.     flex    talkerREF                            local
  94.     flex    rightItem                            local
  95.     flex    triedItem                            local
  96.     flex    forceTalk                            local
  97.     flex    forceLine                            local
  98.     
  99.     int        key=53                                local # tikikey == key[0]
  100.     int        monkeykey=54                        local
  101.     int        h20key=55                            local
  102.     int        divrm1key=58                        local
  103.     int        divrm2key=59                        local
  104.     int        padkey=61                            local
  105.     int        elevkey=68                            local
  106.     int        pyramidkey=84                        local
  107.     int        sharkkey=85                            local
  108.     int        sealkey=87                            local
  109.     int        squarekeys=98                        local # keys plural?
  110.     int        tikikey2=99                            local
  111.     int        turnerkey=102                        local
  112.     int        bronzekey=103                        local
  113.     int        cuffkey=110                            local
  114.     int        oldladykey=115                        local
  115.     int        sharkgatekey=116                    local
  116.  
  117.     int        keyindex                            local # indexes int array
  118.     int        keyItem                                local # flags wrong key use
  119.     int        keytotal=17                            local # define total number of keys
  120.  
  121.     int        lineindex                            local # indexes sound array
  122.     int        rightkeyoffset=0                    local # define
  123.     int        wrongkeyoffset=7                    local # define 
  124.     int        wrongitemoffset=11                    local # define
  125.     int        lockoffset=18                        local # define
  126.     int        wontopenoffset=25                    local # define
  127.  
  128.     int        alreadyworking=0                    local
  129.  
  130.     int        rk_newline=50                        local # init outside actual range
  131.     int        rk_oldline=50                        local
  132.     int        wk_newline=50                        local
  133.     int        wk_oldline=50                        local
  134.     int        wi_newline=50                        local
  135.     int        wi_oldline=50                        local
  136.     int        dl_newline=50                        local
  137.     int        dl_oldline=50                        local
  138.     int        wo_newline=50                        local
  139.     int        wo_oldline=50                        local
  140.  
  141.     int        dummy
  142.     
  143. end
  144.  
  145. # ==============================================================================
  146.  
  147. code
  148.  
  149. # ..............................................................................
  150.  
  151. user0:
  152.  
  153.     # Indy reacts verbally to a locked door player has ACTIVATED in some way...
  154.     #
  155.     # Proper command to reach this response section from the calling cog is:
  156.     #
  157.     # SendMessageEx(lockdoorcogREF, user0, f_talkerREF, f_rightItem, f_triedItem, 0);
  158.     #
  159.     # global15 is used by this cog and the calling cog, like so:
  160.     #
  161.     # global15 == 0 while this cog is at work (waiting for line to finish)
  162.     # global15 == 1 upon return if the player failed to open the door
  163.     # global15 == 2 upon return if the player succeeded
  164.     #
  165.     # The calling cog can use the 0 value as a semaphore to pause execution, thus:
  166.     #
  167.     # while (global15 == 0)
  168.     # {
  169.     #    # Wait for line to finish...
  170.     #    Sleep(0.01);
  171.     # }
  172.  
  173.     if (alreadyworking > 0)
  174.     {
  175.         return;
  176.     }
  177.  
  178.     global15 = 0; # init each call
  179.  
  180.     talkerREF = GetParam(0); # is player or an actor talking? (a cast!)
  181.     rightItem = GetParam(1); # what player must use
  182.     triedItem = GetParam(2); # what player did use
  183.     
  184.     alreadyworking = 1; # stall multiple calls
  185.     
  186.     if (rightItem == triedItem)
  187.     {
  188.         # player has right key and is using it properly
  189.         call randrightkeylines;
  190.         global15 = 2;
  191.     }
  192.     else
  193.     {
  194.         if (triedItem == 0)
  195.         {
  196.             # player isn't using anything
  197.             call randlocklines;
  198.             global15 = 1;
  199.         }
  200.         else
  201.         {
  202.             call checkforkey;
  203.             if (keyItem != 0)
  204.             {
  205.                 # player is using the wrong key
  206.                 call randwrongkeylines;
  207.                 global15 = 1;
  208.             }
  209.             else
  210.             {
  211.                 # player is using a wrong non-key item
  212.                 call randwrongitemlines;
  213.                 global15 = 1;
  214.             }
  215.         }
  216.     }
  217.         
  218.     alreadyworking = 0; # clear to call again
  219.  
  220.     return;
  221.         
  222. # ........................................................................................
  223.  
  224. user1:
  225.  
  226.     # NOTE: Indy notes success with RIGHT KEY without taking any other action...
  227.     #
  228.     # Proper command to reach this response section from the calling cog is:
  229.     #
  230.     # SendMessageEx(doortalkcogREF, user1, f_talkerREF, f_forceTalk, f_forceLine, 0);
  231.     #
  232.     # global15 is used here like so:
  233.     #
  234.     # global15 == 0 while this cog is at work (waiting for line to finish)
  235.     # global15 == 1 upon return
  236.     #
  237.     # As discussed in user0 section, the calling cog can use global15 as a semaphore
  238.     #
  239.     # Hey!  You can also force a line choice.  Here's how:
  240.     # 1. Note your intention by setting f_forceTalk parm to some non-zero value
  241.     # 2. Examine the available lines to find the one you want (counting from 0)
  242.     # 3. Pass that number in the forceLine parameter (parm2) 
  243.  
  244.     if (alreadyworking > 0)
  245.     {
  246.         return;
  247.     }
  248.  
  249.     global15 = 0; # init each call
  250.  
  251.     talkerREF = GetParam(0); # is player or an actor talking? (a cast)
  252.     forceTalk = GetParam(1); # force a choice
  253.     forceLine = GetParam(2); # actual line choice
  254.     
  255.     alreadyworking = 1; # stall multiple calls
  256.  
  257.     if (forceTalk > 0)
  258.     {
  259.         rk_newline = forceLine; # choose this line
  260.         rk_oldline = 0;
  261.     }
  262.  
  263.     call randrightkeylines;
  264.     global15 = 1;
  265.     alreadyworking = 0;
  266.  
  267.     return;
  268.  
  269. # ........................................................................................
  270.  
  271. user2:
  272.  
  273.     # NOTE: Indy notes player has tried WRONG KEY... 
  274.     #
  275.     # Proper command to reach this response section from the calling cog is:
  276.     #
  277.     # SendMessageEx(doortalkcogREF, user2, f_talkerREF, f_forceTalk, f_forceLine, 0);
  278.     #
  279.     # global15 is used here like so:
  280.     #
  281.     # global15 == 0 while this cog is at work (waiting for line to finish)
  282.     # global15 == 1 upon return
  283.     #
  284.     # As discussed in user0 section, the calling cog can use global15 as a semaphore;
  285.     #
  286.     # As discussed in user1 section, you can also force a line choice.
  287.  
  288.     if (alreadyworking > 0)
  289.     {
  290.         return;
  291.     }
  292.  
  293.     global15 = 0; # init each call
  294.  
  295.     talkerREF = GetParam(0); # is player or an actor talking? (a cast)
  296.     forceTalk = GetParam(1); # force a choice
  297.     forceLine = GetParam(2); # actual line choice
  298.     
  299.     alreadyworking = 1; # stall multiple calls
  300.  
  301.     if (forceTalk > 0)
  302.     {
  303.         wk_newline = forceLine; # choose this line
  304.         wk_oldline = 0;
  305.     }
  306.  
  307.     call randwrongkeylines;
  308.     global15 = 1;
  309.     alreadyworking = 0;
  310.  
  311.     return;
  312.  
  313. # ........................................................................................
  314.  
  315. user3:
  316.  
  317.     # NOTE: Indy notes use of a WRONG ITEM...
  318.     #
  319.     # Proper command to reach this response section from the calling cog is:
  320.     #
  321.     # SendMessageEx(doortalkcogREF, user3, f_talkerREF, f_forceTalk, f_forceLine, 0);
  322.     #
  323.     # global15 is used here like so:
  324.     #
  325.     # global15 == 0 while this cog is at work (waiting for line to finish)
  326.     # global15 == 1 upon return
  327.     #
  328.     # As discussed in user0 section, the calling cog can use global15 as a semaphore;
  329.     #
  330.     # As discussed in user1 section, you can also force a line choice.
  331.  
  332.     if (alreadyworking > 0)
  333.     {
  334.         return;
  335.     }
  336.  
  337.     global15 = 0; # init each call
  338.  
  339.     talkerREF = GetParam(0); # is player or an actor talking? (a cast)
  340.     forceTalk = GetParam(1); # force a choice
  341.     forceLine = GetParam(2); # actual line choice
  342.     
  343.     alreadyworking = 1; # stall multiple calls
  344.  
  345.     if (forceTalk > 0)
  346.     {
  347.         wi_newline = forceLine; # choose this line
  348.         wi_oldline = 0;
  349.     }
  350.  
  351.     call randwrongitemlines;
  352.     global15 = 1;
  353.     alreadyworking = 0;
  354.  
  355.     return;
  356.  
  357. # ........................................................................................
  358.  
  359. user4:
  360.  
  361.     # NOTE: Indy acknowledges a LOCKED DOOR...
  362.     #
  363.     # Proper command to reach this response section from the calling cog is:
  364.     #
  365.     # SendMessageEx(doortalkcogREF, user4, f_talkerREF, f_forceTalk, f_forceLine, 0);
  366.     #
  367.     # global15 is used here like so:
  368.     #
  369.     # global15 == 0 while this cog is at work (waiting for line to finish)
  370.     # global15 == 1 upon return
  371.     #
  372.     # As discussed in user0 section, the calling cog can use global15 as a semaphore;
  373.     #
  374.     # As discussed in user1 section, you can also force a line choice.
  375.  
  376.     if (alreadyworking > 0)
  377.     {
  378.         return;
  379.     }
  380.  
  381.     global15 = 0; # init each call
  382.  
  383.     talkerREF = GetParam(0); # is player or an actor talking? (a cast)
  384.     forceTalk = GetParam(1); # force a choice
  385.     forceLine = GetParam(2); # actual line choice
  386.     
  387.     alreadyworking = 1; # stall multiple calls
  388.  
  389.     if (forceTalk > 0)
  390.     {
  391.         dl_newline = forceLine; # choose this line
  392.         dl_oldline = 0;
  393.     }
  394.  
  395.     call randlocklines;
  396.     global15 = 1;
  397.     alreadyworking = 0;
  398.  
  399.     return;
  400.  
  401. # ........................................................................................
  402.  
  403. user5:
  404.  
  405.     # NOTE: Indy notes a DOOR with no obvious lock that JUST WON'T OPEN...
  406.     #
  407.     # Proper command to reach this response section from the calling cog is:
  408.     #
  409.     # SendMessageEx(doortalkcogREF, user5, f_talkerREF, f_forceTalk, f_forceLine, 0);
  410.     #
  411.     # global15 is used here like so:
  412.     #
  413.     # global15 == 0 while this cog is at work (waiting for line to finish)
  414.     # global15 == 1 upon return
  415.     #
  416.     # As discussed in user0 section, the calling cog can use global15 as a semaphore;
  417.     #
  418.     # As discussed in user1 section, you can also force a line choice.
  419.  
  420.     if (alreadyworking > 0)
  421.     {
  422.         return;
  423.     }
  424.  
  425.     global15 = 0; # init each call
  426.  
  427.     talkerREF = GetParam(0); # is player or an actor talking? (a cast)
  428.     forceTalk = GetParam(1); # force a choice
  429.     forceLine = GetParam(2); # actual line choice
  430.     
  431.     alreadyworking = 1; # stall multiple calls
  432.  
  433.     if (forceTalk > 0)
  434.     {
  435.         wo_newline = forceLine; # choose this line
  436.         wo_oldline = 0;
  437.     }
  438.  
  439.     call randwontopenlines;
  440.     global15 = 1;
  441.     alreadyworking = 0;
  442.  
  443.     return;
  444.  
  445. # ........................................................................................
  446.  
  447. checkforkey:
  448.  
  449.     keyItem = 0; # init each time thru
  450.  
  451.     for (keyindex = 0; keyindex < keytotal; keyindex = keyindex + 1)
  452.     {
  453.         if (triedItem == key[keyindex])
  454.         {
  455.             keyItem = key[keyindex];
  456.         }
  457.     }
  458.             
  459.     return;
  460.  
  461. # ........................................................................................
  462.  
  463. randrightkeylines:
  464.  
  465.     # NOTE: never say same line twice in a row
  466.     # and say some lines less frequently than others
  467.     
  468.     while (rk_newline == rk_oldline)
  469.     {        
  470.         rk_newline = RandBetween(0, 9);
  471.         if (rk_newline > 7)
  472.         {
  473.             rk_newline = (rk_newline - 3); # 1/10 chance for lines 5 or 6
  474.         }
  475.          else
  476.         {    
  477.             rk_newline = RandBetween(0, 4); # 1/5 chance for lines 0 thru 4
  478.         }
  479.     }
  480.     rk_oldline = rk_newline; # remember choice
  481.     lineindex = rightkeyoffset + rk_newline;
  482.  
  483.     PlayVoice(talkerREF, in_sayline[lineindex], 1, 1);
  484.  
  485.     return;
  486.  
  487. # ..............................................................................
  488.  
  489. randwrongkeylines:
  490.  
  491.     while (wk_newline == wk_oldline)
  492.     {        
  493.         wk_newline = RandBetween(0, 3);
  494.     }
  495.     wk_oldline = wk_newline;
  496.     lineindex = wrongkeyoffset + wk_newline; # 1/4 chance
  497.  
  498.     PlayVoice(talkerREF, in_sayline[lineindex], 1, 1);
  499.  
  500.     return;
  501.  
  502. # ..............................................................................
  503.  
  504. randwrongitemlines:
  505.  
  506.     while (wi_newline == wi_oldline)
  507.     {        
  508.         wi_newline = RandBetween(0, 19);
  509.         if (wi_newline < 15)
  510.         {    
  511.             wi_newline = RandBetween(0, 3); # ~1/5 chance for lines 0 thru 3
  512.         }
  513.  
  514.         if (wi_newline == 19)
  515.         {
  516.             wi_newline = 6; # 1/20 chance for line 6 
  517.         }
  518.         if (wi_newline > 16)
  519.         {
  520.             wi_newline = 5; # 1/10 chance for line 5 
  521.         }
  522.         if (wi_newline > 14)
  523.         {
  524.             wi_newline = 4; # 1/10 chance for line 4
  525.         }
  526.     }
  527.     wi_oldline = wi_newline;    
  528.     lineindex = wrongitemoffset + wi_newline;
  529.  
  530.     PlayVoice(talkerREF, in_sayline[lineindex], 1, 1);
  531.  
  532.     return;
  533.  
  534. # ..............................................................................
  535.  
  536. randlocklines:
  537.  
  538.     while (dl_newline == dl_oldline)
  539.     {        
  540.         dl_newline = RandBetween(0, 19);
  541.         if (dl_newline < 14)
  542.         {    
  543.             dl_newline = RandBetween(0, 2); # ~1/4 chance for 0 thru 2
  544.         }
  545.  
  546.         if (dl_newline > 17)
  547.         {
  548.             dl_newline = (dl_newline - 13); # 1/20 chance for 5 or 6 
  549.         }    
  550.         if (dl_newline > 15)
  551.         {
  552.             dl_newline = 4; # 1/10 chance
  553.         }
  554.         if (dl_newline > 13)
  555.         {
  556.             dl_newline = 3; # 1/10 chance
  557.         }
  558.     }
  559.     dl_oldline = dl_newline;
  560.     lineindex = lockoffset + dl_newline;
  561.  
  562.     PlayVoice(talkerREF, in_sayline[lineindex], 1, 1);
  563.  
  564.     return;
  565.  
  566. # ..............................................................................
  567.  
  568. randwontopenlines:
  569.  
  570.     while (wo_newline == wo_oldline)
  571.     {        
  572.         wo_newline = RandBetween(0, 4);
  573.     }
  574.     wo_oldline = wo_newline;
  575.     lineindex = wontopenoffset + wo_newline; # 1/5 chance
  576.  
  577.     PlayVoice(talkerREF, in_sayline[lineindex], 1, 1);
  578.  
  579.     return;
  580.  
  581. end
  582.  
  583.